<?php
session_start();
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
require_once("lib/my_library.php");
//Includes
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtdatepicker.inc.php");
use_unit("comctrls.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Veh_Fuel_Create extends Page
{
       public $edNo = null;
       public $lblNo = null;
       public $cmbmode = null;
       public $Label3 = null;
       public $JSRoundDecimal = null;
       public $Label12 = null;
       public $hfError = null;
       public $JSValidate = null;
       public $lblprice = null;
       public $lblli = null;
       public $lblcurrod = null;
       public $lblftype = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $dpdate = null;
       public $edType = null;
       public $btnAddType = null;
       public $btnDelType = null;
       public $listType = null;
       public $JTDivType = null;
       public $JTGroupBox5 = null;
       public $btnShowType = null;
       public $JTJavaScript15 = null;
       public $JTJavaScript14 = null;
       public $JTJavaScript13 = null;
       public $JTDivCity = null;
       public $edCity = null;
       public $btnAddCity = null;
       public $btnDelCity = null;
       public $listCity = null;
       public $JTGroupBox4 = null;
       public $btnShowCity = null;
       public $JTJavaScript12 = null;
       public $JTJavaScript11 = null;
       public $JTJavaScript10 = null;
       public $JTDivDealer = null;
       public $JTGroupBox3 = null;
       public $btnaddDealer = null;
       public $btnDelDealer = null;
       public $edDealer = null;
       public $listDealer = null;
       public $JTDivAccount = null;
       public $JTGroupBox1 = null;
       public $btnAddAccount = null;
       public $btnDelAccount = null;
       public $edAccount = null;
       public $listAccount = null;
       public $JTDivFuel = null;
       public $JTGroupBox2 = null;
       public $btnAddFuel = null;
       public $btnDelFuel = null;
       public $edFuel = null;
       public $listFuel = null;
       public $JTJavaScript9 = null;
       public $JTJavaScript8 = null;
       public $JTJavaScript7 = null;
       public $JTJavaScript6 = null;
       public $JTJavaScript5 = null;
       public $JTJavaScript4 = null;
       public $JTJavaScript3 = null;
       public $JTJavaScript2 = null;
       public $JTJavaScript1 = null;
       public $compid = null;
       public $btnShowDealer = null;
       public $btnShowFuel = null;
       public $btnShowAccount = null;
       public $Label2 = null;
       public $imgBack = null;
       public $Image3 = null;
       public $edPrice = null;
       public $Label1 = null;
       public $JTDatePicker_date = null;
       public $edEngine = null;
       public $lblEngine = null;
       public $hiddenLine = null;
       public $cmbDealer = null;
       public $edOdLast = null;
       public $edOdNow = null;
       public $edMiles = null;
       public $edGallons = null;
       public $edTotCost = null;
       public $cmbBrand = null;
       public $cmbCity = null;
       public $cmbAccount = null;
       public $cmbType = null;
       public $cmbDriver = null;
       public $memoComments = null;
       public $lblComments = null;
       public $lblType = null;
       public $lblCity = null;
       public $lblDealer = null;
       public $lblBrand = null;
       public $lblDriver = null;
       public $lblAccount = null;
       public $lblTotal = null;
       public $lblMiles = null;
       public $lblOdometerNow = null;
       public $lblLastOdometer = null;
       public $lblDate = null;
       public $JTSiteTheme1 = null;
       function cmbmodeJSChange($sender, $params)
       {

       ?>
       var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

       <?php

       }



       function Veh_Fuel_CreateJSLoad($sender, $params)
       {

       ?>
       var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

       <?php

       }



       function edPriceJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edPrice','lblprice');
       <?php

       }

       function edGallonsJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edGallons','lblli');
       <?php

       }

       function edOdNowJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edOdNow','lblcurrod');
       <?php

       }


       function cmbTypeJSChange($sender, $params)
       {
       echo $this->cmbType->ajaxCall('price');
       ?>
       return false;

       <?php

       }

       function cmbBrandJSChange($sender, $params)
       {
       echo $this->cmbBrand->ajaxCall('price');
       ?>
       return false;

       <?php

       }

       function price()
       {
        $type_id = $this->cmbType->getItemIndex();
        $brand = $this->cmbBrand->getItemIndex();

        $query_type = "SELECT value FROM lookup_fuel_tbl WHERE id='".$type_id."'";
        $result_type = mysql_query($query_type) or die("SELECT FUEL TYPE ".mysql_error());
        $row_type = mysql_fetch_array($result_type);
        $type = $row_type['value'];

        $query_price = "SELECT price FROM fuel_price_tbl WHERE company_id='".$_SESSION['company_id']."' AND brand='".$brand."' AND type='".$type."'";
        $result_price = mysql_query($query_price) or die("SELECT PRICE ".mysql_error());
        $row_price = mysql_fetch_array($result_price);

        $price = $row_price['price'];
        $this->edPrice->Text = $price;

        $total = $this->edPrice->Text * $this->edGallons->Text;
        $this->edTotCost->setText($total);
       }

       function btnDelTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var TypeIndex = document.getElementById('listType').selectedIndex;
       var TypeValue = document.getElementById('listType')[TypeIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxType3(TypeValue,comp);
       <?php

       }

       function btnAddTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addtype = document.getElementById('edType').value;

       var compider = document.getElementById('compid').value;
       AjaxType2(addtype,compider);
       document.Veh_Fuel_Create.edType.value = "";
       <?php

       }

       function btnShowTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivType').Show();
       document.Veh_Fuel_Create.edType.value = "";
       <?php

       }

       function btnShowCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivCity').Show();
       document.Veh_Fuel_Create.edCity.value = "";
       <?php

       }

       function btnAddCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addcity = document.getElementById('edCity').value;
       var compider = document.getElementById('compid').value;
       AjaxCity2(addcity,compider);
       document.Veh_Fuel_Create.edCity.value = "";
       <?php

       }

       function btnDelCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var CityIndex = document.getElementById('listCity').selectedIndex;
       var CityValue = document.getElementById('listCity')[CityIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxCity3(CityValue,comp);
       <?php

       }


       function btnShowDealerJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivDealer').Show();
       document.Veh_Fuel_Create.edDealer.value = "";
       <?php

       }

       function btnDelDealerJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var DealerIndex = document.getElementById('listDealer').selectedIndex;
       var DealerValue = document.getElementById('listDealer')[DealerIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxDealer3(DealerValue,comp);
       <?php

       }

       function btnaddDealerJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var adddealer = document.getElementById('edDealer').value;
       var compider = document.getElementById('compid').value;
       AjaxDealer2(adddealer,compider);
       document.Veh_Fuel_Create.edDealer.value = "";
       <?php

       }

       function btnAddFuelJSClick($sender, $params)
        {

       ?>
       //Add your javascript code here
       var addfuel = document.getElementById('edFuel').value;
       var compider = document.getElementById('compid').value;
       AjaxFuel2(addfuel,compider);
       document.Veh_Fuel_Create.edFuel.value = "";
       <?php

       }

      function btnDelFuelJSClick($sender, $params)
      {

      ?>
       //Add your javascript code here
     var FuelIndex = document.getElementById('listFuel').selectedIndex;
     var FuelValue = document.getElementById('listFuel')[FuelIndex].value;
     var comp = document.getElementById('compid').value;
     AjaxFuel3(FuelValue,comp);
     <?php

      }

      function btnShowFuelJSClick($sender, $params)
      {

      ?>
      //Add your javascript code here
      document.getElementById('JTDivFuel').Show();
      document.Veh_Fuel_Create.edFuel.value = "";
      <?php

      }


      function btnDelAccountJSClick($sender, $params)
      {

      ?>
      //Add your javascript code here
      var dropdownIndex = document.getElementById('listAccount').selectedIndex;
      var dropdownValue = document.getElementById('listAccount')[dropdownIndex].value;
      var com = document.getElementById('compid').value;
      AjaxAccount3(dropdownValue,com);
      <?php

       }

      function btnAddAccountJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addaccount = document.getElementById('edAccount').value;
       var compider = document.getElementById('compid').value;
       AjaxAccount2(addaccount,compider);
       document.Veh_Fuel_Create.edAccount.value = "";
       <?php

       }

       function btnShowAccountJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivAccount').Show();
       document.Veh_Fuel_Create.edAccount.value = "";
       <?php

       }


       function edPriceJSKeyUp($sender, $params)
       {

       ?>
       document.Veh_Fuel_Create.edTotCost.value = roundNumber((document.Veh_Fuel_Create.edGallons.value) * (document.Veh_Fuel_Create.edPrice.value),2);


       //accept only numbers
       var numero = document.getElementById("edPrice").value;
       var first = numero.indexOf('.');
       var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("edPrice").value = numero;

       <?php

       }

       function edGallonsJSKeyUp($sender, $params)
       {

       ?>
       document.Veh_Fuel_Create.edTotCost.value = roundNumber((document.Veh_Fuel_Create.edGallons.value) * (document.Veh_Fuel_Create.edPrice.value),2);
       <?php
       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function edOdLastJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Veh_Fuel_Create.edMiles.value = (document.Veh_Fuel_Create.edOdNow.value) - (document.Veh_Fuel_Create.edOdLast.value);
       <?php

       }

       function edOdNowJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Veh_Fuel_Create.edMiles.value = (document.Veh_Fuel_Create.edOdNow.value) - (document.Veh_Fuel_Create.edOdLast.value);
       <?php

       }

       function btnCancelClick($sender, $params)
       {
       redirect('veh_fuel_list.php?veh='.$this->hiddenLine->getValue());


       }



       function btnSubmitClick($sender, $params)
       {
       $my_library = new my_library();

       $vehicle_id = $this->hiddenLine->getValue();
       $driver_autoid = $this->cmbDriver->getItemIndex();
       $result_driver = mysql_query("SELECT * FROM employee_tbl WHERE autoid='".$driver_autoid."'")
       or die("GET DRIVER ".mysql_error());
       $row_driver = mysql_fetch_array($result_driver);

       //$my_library->updateCurrentTrackingValue($vehicle_id, $this->edOdNow->Text);

       $fuel_t = $this->cmbType->getItemIndex();
       $result_ftype = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND id='".$fuel_t."'");
       $row_ftype = mysql_fetch_array($result_ftype);
       $ftype2 = $row_ftype['value'];


       //die($this->edOdNow->Text);
       //$this->validateRequired($this->edOdNow->Text, 'lblcurrod');
       $this->validateRequired($this->edGallons->Text, 'lblli');
       $this->validateRequired($this->edPrice->Text, 'lblprice');
       $error = $this->hfError->getValue();
       if($error == '1' || $number != $key)
       {
          $this->hfError->setValue('0');
          return false;
       }
       else if($error == '0')
       {
       $query1 = "select * from vehicle_tbl where vehicle_id='".$this->hiddenLine->getValue()."'";
       $result = mysql_query($query1)or die(mysql_error());
       $row = mysql_fetch_array($result);
       $track = $row['track_by'];

       $result = mysql_query("insert into veh_fuel_tbl (company_id,
       vehicle_id,
       date,
       payment_mode,
       card_num,
       track_by,
       last_odometer,
       present_odometer,
       miles,
       gallons,
       price,
       tot_cost,
       engine,
       brand,
       dealer,
       account,
       province,
       driver,
       driver_id,
       type,
       ftype_id,
       comments)

       values ('".$_SESSION['company_id']."',
       '".$vehicle_id."',
       '".$this->dpdate->Text."',
       '".$this->cmbmode->getItemIndex()."',
       '".$this->edNo->Text."',
       '".$track."',
       '".$this->edOdLast->Text."',
       '".$this->edOdNow->Text."',
       '".$this->edMiles->Text."',
       '".$this->edGallons->Text."',
       '".$this->edPrice->Text."',
       '".$this->edTotCost->Text."',
       '".$this->edEngine->Text."',
       '".$this->cmbBrand->getItemIndex()."',
       '".$this->cmbDealer->getItemIndex()."',
       '".$this->cmbAccount->getItemIndex()."',
       '".$this->cmbCity->getItemIndex()."',
       '".$row_driver['lname'].','.$row_driver['fname']."',
       '".$driver_autoid."',
       '".$ftype2."',
       '".$this->cmbType->getItemIndex()."',
       '".$this->memoComments->Text."')");


       //UPDATE CURRENT ODOMETER/HOUR
      if($track=='distance')
      {
      $curr_track = $row['curr_tracking_value'];
      $save_here = 'curr_tracking_value';
      }

      if($track=='hours')
      {
      $curr_track = $row['curr_hours'];
      $save_here = 'curr_hours';
      }

      $fuel_currod = $this->edOdNow->Text;
      if($fuel_currod>=$curr_track)
      {
      mysql_query("UPDATE vehicle_tbl set ".$save_here." = '".$this->edOdNow->Text."' WHERE vehicle_id = '".$this->hiddenLine->getValue()."'")or die(mysql_error());
      }


       //redirect('veh_fuel_list.php?veh='.$vehicle_id);
       echo "<script type='text/javascript'>
       var answer = confirm('Add another record?');
       if(answer)
       {
       window.location = 'veh_fuel_create.php?veh=".$vehicle_id."';
       }
       else
       {
       window.location = 'veh_fuel_list.php?veh=".$vehicle_id."';
       }
       </script>";
       }
       }

       function validateRequired($value, $lbl)
       {
          if($value == '' || $value == null)
          {
             $this->$lbl->Caption = '&darr; This field is required &darr;';
             $this->hfError->setValue('1');
          }
       }



       function Veh_Fuel_CreateCreate($sender, $params)
       {
       $this->compid->Value = $_SESSION['company_id'];
       $veh_id = $_GET['veh'];
       $this->hiddenLine->setValue($veh_id);
       $this->hfError->setValue('0');

       $this->lblcurrod->Caption = '';
       $this->lblli->Caption = '';
       $this->lblprice->Caption = '';


       $this->imgBack->setLink('veh_fuel_list.php?veh='.$this->hiddenLine->getValue());

       $this->dpdate->Text = "";
       $this->edOdLast->Text = "";
       $this->edOdNow->Text = "";
       $this->edMiles->Text = "";
       $this->edGallons->Text = "";
       $this->edTotCost->Text = "";
       $this->memoComments->Text = "";
       $this->edPrice->Text = "";
       $this->edNo->Text = "";
       $this->cmbmode->setItemIndex('Select');


       $query1 = "select * from vehicle_tbl where vehicle_id='".$this->hiddenLine->getValue()."'";
       $result = mysql_query($query1)or die(mysql_error());
       $row = mysql_fetch_array($result);

       $this->edOdLast->Text=$row['curr_tracking_value'];
       $this->edEngine->Text=$row['engine_model'];


       $label_od = $row['track_by'];
       if ($label_od=='distance')
        {
        $this->lblLastOdometer->Caption = 'Previous Odometer:';
        $this->lblOdometerNow->Caption = '*Current Odometer:';
        //$this->lblOdometerNow->Left = 410;
        }
       if ($label_od=='hours')
        {
        $this->lblLastOdometer->Caption = 'Previous Hours:';
        $this->lblOdometerNow->Caption = '*Current Hours:';
        //$this->lblOdometerNow->Left = 415;
        }



      /*$result_engine = mysql_query("select * from vehicle_tbl where vehicle_id='".$this->hiddenLine->getValue()."'");
      $row_engine = mysql_fetch_array($result_engine);


      $this->edOdLast->Text=$row_engine['curr_tracking_value'];
      $this->edEngine->Text=$row_engine['engine_model'];*/

      $this->cmbDriver->Clear();
       $result_driver = mysql_query("select * from employee_tbl where company_id='".$_SESSION['company_id']."' and veh_op='1'");

       while($row_driver = mysql_fetch_array($result_driver))
       {
            $this->cmbDriver->AddItem($row_driver['lname'].','.$row_driver['fname'], null, $row_driver['autoid']);
       }


      $query_fluid = "select * from veh_fluids_tbl where vehicle_id='".$this->hiddenLine->getValue()."'";
      $result_fluid = mysql_query($query_fluid)or die(mysql_error());
      $row_fluid = mysql_fetch_array($result_fluid);
      $ftype = $row_fluid['fuel_type'];

      $result_ftype = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND id='".$ftype."'");
      $row_ftype = mysql_fetch_array($result_ftype);
      $ftype2 = $row_ftype['value'];

      $this->lblftype->Caption = $ftype2;

      $this->cmbType->Clear();
      $this->cmbType->AddItem('--Select--',null,null);
      $this->cmbType->setItemIndex('--Select--');
      //$this->cmbType->ItemIndex = $ftype;
      $result_fuel = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='octane/Types' order by value asc");

      while($row_fuel = mysql_fetch_array($result_fuel))
      {
        $this->cmbType->AddItem($row_fuel['value'], null, $row_fuel['id']);
      }
     //list type/grade
     $this->listType->Clear();
      $result_type = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='octane/Types' order by value asc");

      while($row_type = mysql_fetch_array($result_type))
      {
        $this->listType->AddItem($row_type['value'], null, $row_type['id']);
      }



      $this->cmbCity->Clear();
      $result_city = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='state/province'");

      while($row_city = mysql_fetch_array($result_city))
      {
        $this->cmbCity->AddItem($row_city['value'], null, $row_city['value']);
      }

      //list city
      $this->listCity->Clear();
      $result_ci = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='state/province'");

      while($row_ci = mysql_fetch_array($result_ci))
      {
        $this->listCity->AddItem($row_ci['value'], null, $row_ci['value']);
      }

      $this->cmbAccount->Clear();
      $this->cmbAccount->AddItem('--Select--',null,null);
      $this->cmbAccount->setItemIndex('--Select--');
      $result_account = mysql_query("select * from lookup_expense_tbl where company_id = '".$_SESSION['company_id']."' AND category='accounts'");

      while($row_account = mysql_fetch_array($result_account))
      {
        $this->cmbAccount->AddItem($row_account['value'], null, $row_account['id']);
      }

      //list account
      $this->listAccount->Clear();
      $result_acc = mysql_query("select * from lookup_expense_tbl where company_id = '".$_SESSION['company_id']."' AND category='accounts'");

      while($row_acc = mysql_fetch_array($result_acc))
      {
        $this->listAccount->AddItem($row_acc['value'], null, $row_acc['id']);
      }

       $result_fuel = mysql_query("select max(present_odometer) as curr_max from veh_fuel_tbl where company_id='".$_SESSION['company_id']."' and vehicle_id='".$this->hiddenLine->getValue()."'");
       $row_fuel = mysql_fetch_array($result_fuel);
       $curr_fuel = $row_fuel['curr_max'];
       //$this->edOdLast->Text=$curr_fuel;

       /*$result_od = mysql_query("select * from vehicle_tbl where vehicle_id='".$this->hiddenLine->getValue()."'");
       $row_od = mysql_fetch_array($result_od);
       $label_od = $row_od['track_by'];
       if ($label_od=='distance')
       {
        $this->lblOdometerNow->Caption = 'Current Odometer:';
        $this->lblLastOdometer->Caption = 'Last Odometer:';
       }
       else
       {
        $this->lblOdometerNow->Caption = 'Clock Hrs Now:';
        $this->lblLastOdometer->Caption = 'Last Clock Hrs:';
       }*/

       /*$result_od2 = mysql_query("select * from company_measures_tbl where company_id='".$_SESSION['company_id']."'");
       $row_od2 = mysql_fetch_array($result_od2);
       $label_od2 = $row_od2['custom_field'];
       if($label_od2=='1')
       {
       $this->lblOdometerNow->Caption = 'Curr Meter:';
       $this->lblOdometerNow->Left= 426;
       $this->lblLastOdometer->Caption = 'Last Meter:';
       $this->lblLastOdometer->Left= 252;
       $this->lblMiles->Caption = 'Distance:';
       $this->lblMiles->Left= 596;
       $this->lblGallons->Caption = 'Vol Units:';
       $this->lblGallons->Left= 46;
       $this->lblGallons->Width = 58;
       }
       else
       {
       $this->lblOdometerNow->Left= 402;
       $this->lblLastOdometer->Left= 220;
       $this->lblMiles->Caption = 'Miles:';
       $this->lblMiles->Left= 601;
       $this->lblGallons->Caption = 'Gallons:';
       $this->lblGallons->Left= 54;
       $this->lblGallons->Width = 46;
       } */

       $this->cmbBrand->Clear();
       $this->cmbBrand->AddItem('--Select--',null,null);
       $this->cmbBrand->setItemIndex('--Select--');
       $result_brand = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='brands' order by value asc");

       while($row_brand = mysql_fetch_array($result_brand))
        {
            $this->cmbBrand->AddItem($row_brand['value'], null, $row_brand['value']);
        }

       //list brand
       $this->listFuel->Clear();
      $result_brand = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='brands' order by value asc");

      while($row_brand= mysql_fetch_array($result_brand))
      {
         $this->listFuel->AddItem($row_brand['value'], null , $row_brand['value']);
      }

       $this->cmbDealer->Clear();
       $result_dealer = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='dealer names'");

       while($row_dealer = mysql_fetch_array($result_dealer))
        {
            $this->cmbDealer->AddItem($row_dealer['value'], null, $row_dealer['value']);
        }

       //list dealer
       $this->listDealer->Clear();
       $result_deal = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='dealer names'");

       while($row_deal = mysql_fetch_array($result_deal))
        {
            $this->listDealer->AddItem($row_deal['value'], null, $row_deal['value']);
        }


       //$this->dpdate->setText(date("Y-m-d"));
       $this->dpdate->Text = '';

       }

}

global $application;

global $Veh_Fuel_Create;

//Creates the form
$Veh_Fuel_Create = new Veh_Fuel_Create($application);

//Read from resource file
$Veh_Fuel_Create->loadResource(__FILE__);

//Shows the form
$Veh_Fuel_Create->show();

?>